var indextool = {
    //绑定商店下拉函数
    blindPoverBottom:()=>{
        const title = '<div class="panel panel-default"><div class="panel-body text-center" style="color: #888;">您的购物车空空如也</div></div>';
        const content = '<div class="media popoverBorder"><div class="media-left"><a href="#"><img class="media-object" alt="商店" src="../AppleProject/imgs/gouwuchepopover.png"/></a></div><div class="media-body"><p class="media-heading popoverColor">购物车</p></div></div>'+
                        '<div class="media popoverBorder"><div class="media-left"><a href="#"><img class="media-object" alt="商店" src="../AppleProject/imgs/login.png"/></a></div><div class="media-body"><p class="media-heading popoverColor">登录</p></div></div>'+
                        '<div class="media popoverBorder"><div class="media-left"><a href="#"><img class="media-object" alt="商店" src="../AppleProject/imgs/shezhi.png"/></a></div><div class="media-body"><p class="media-heading popoverColor">设置</p></div></div>'+
                        '<div class="media popoverBorder"><div class="media-left"><a href="#"><img class="media-object" alt="商店" src="../AppleProject/imgs/shoucang.png"/></a></div><div class="media-body"><p class="media-heading popoverColor">收藏</p></div></div>';
        $('#poperId').popover({
            trigger:'click',
            placement:'bottom',
            title:title,
            html:'true',
            content:content,
            animation:false,
            container:'body'
        }).on("click",function () {
                $('#poperId').popover('show');
                indextool.blindLogin();
                event.stopPropagation();
        });
    },
    //绑定登陆事件
    blindLogin:()=>{
        $('.popoverBorder').click(function () {
            var index = $(this).index();
            if(index==1){
                $(function () { $('#myModal').modal({
                    keyboard: true
                })});
                $('#poperId').popover('hide');
            }
        })
    },
    // 冒泡取消popover
    cancleBlindPopover:()=>{
        $(document).click(function () {
                $('#poperId').popover('hide');
        })
    },
    //媒体查询
    changImg:()=>{
        window.onresize = function(){
            var screen1 = window.matchMedia('(min-width: 0px) and (max-width: 768px)');
            if (screen1.matches){
                $($('.logo')[0]).attr("src","imgs/iphone_8_small.jpg");
                $($('.logo')[1]).attr("src","imgs/iphone_x_small.jpg");
                $($('.logo')[2]).attr("src","imgs/watchos_small.jpg");
                $($('.logo')[3]).attr("src","imgs/ios_alt_small.jpg");
                indextool.unblindMoblieUl();
                indextool.blindMobileUl();
            }
            else{
                $($('.logo')[0]).attr("src","imgs/iphone_8_large.jpg");
                $($('.logo')[1]).attr("src","imgs/iphone_x_large.jpg");
                $($('.logo')[2]).attr("src","imgs/watchos_large.jpg");
                $($('.logo')[3]).attr("src","imgs/ios_large.jpg");
            }
        }
    },
    blindMobileUl:()=>{
            $(".footerH4").click(function () {
                var index = $(this).parent().prevAll().length;
                var className = $(this).attr("class");
                var selector = "." +  className;
                console.log(selector+":after");
                console.log($(selector+":after").length);

                if(_thisindex==index){
                    console.log($(this).next().css("display"));
                    if($(this).next().css("display")=="none"){
                        $(this).next().css("display","block");
                        $(this).css("borderBottom","0px");
                        $(this).addClass("footerRotate");
                    }
                    else{
                        $(this).next().css("display","none");
                        $(this).css("borderBottom","1px solid lightgrey");
                        $(this).removeClass("footerRotate");
                    }
                }
                else{
                    _thisindex = index;
                    $(selector).next().css("display","none");
                    $(selector).css("borderBottom","1px solid lightgrey");
                    $(selector).removeClass("footerRotate");

                    $(this).css("borderBottom","0px");
                    $(this).next().css("display","block").css("borderBottom","1px solid lightgrey");
                    $(this).addClass("footerRotate");
                }
            })
    },
//  解绑事件
    unblindMoblieUl:()=>{
        $(".footerH4>h4").unbind();
    }
}